/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2022并保留所有权利。
 * Copyright 2022, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.spring.docother.juc.cow;

import java.util.*;
import java.util.concurrent.*;

public class ConcurrentHashMapTest {
    public static void main(String[] args) {
//        Map map = new HashMap<>();
        Map map = Collections.synchronizedMap(new HashMap<>());
//        Map<String,String> map = new ConcurrentHashMap<String,String>();

        for (int i = 0; i < 20; i++) {
            new Thread(() -> {
                map.put(Thread.currentThread().getName(),UUID.randomUUID().toString().substring(0,5));
                System.out.println(Thread.currentThread().getName() + " : "+map);
            },String.valueOf(i)).start();
        }
    }
}
